import Http from '../http';
import { SysUser } from '@/model/user/user';
import { UpdateIsOpenInPut, UserRoleInput } from '@/model/public/public';

//获取所有用户
export const getUser = async function (params?: { departmentId?: string }) {
  return await Http.get('/api/SysUser/GetUser', params);
}

//获取公司人员
export const getCorporationUser = async function (pageResultModel: any) {
  return await Http.post('/api/SysUser/GetCorporationUser', pageResultModel);
}

//新增用户
export const insert = function (sysUser: SysUser) {
  return Http.post('/api/SysUser/Insert', sysUser)
}

//编辑用户
export const update = function (sysUser: SysUser) {
  return Http.post('/api/SysUser/Update', sysUser)
}

//设置用户是否启用
export const setUserIsOpen = function (updateCorporationIsOpenInPut: UpdateIsOpenInPut) {
  return Http.post('/api/SysUser/SetUserIsOpen', updateCorporationIsOpenInPut)
}

//获取当前登录人员日志,并写入数据库
export const getLoginOrInsert = async function () {
  return await Http.get('/api/SysUser/GetLoginOrInsert');
}

//获取登录日志
export const getLoginLogMsg = async function (pageResultModel: any) {
  return await Http.post('/api/SysUser/GetLoginLogMsg', pageResultModel);
}

//设置用户角色
export const setUserRole = function (userRoleInput: UserRoleInput) {
  return Http.post('/api/SysUser/SetUserRole', userRoleInput)
}

//根据用户id获取对应角色
export const getUserRole = async function (params?: { userId?: string }) {
  return await Http.get('/api/SysUser/GetUserRole', params);
}

//获取公司人员
export const GetCorporationUser = async function (params: { corporationKey: string }) {
  return await Http.get('/api/SysUser/GetCorporationUser', params);
}

//根据角色获取绑定用户
export const GetBindUser = async function (params: { roleId: number | undefined | string }) {
  return await Http.get('/api/SysUser/GetBindUser', params);
}
//获取公司人员,用于登录
export const getUserByCorporationKey = async function (params: { corporationKey: string }) {
  return await Http.get('/api/SysUser/GetUserByCorporationKey', params);
}

